using MicroMsg.Manager;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace MicroMsg.UI.UserContrl
{
	public class PostPhotoWithHeadImg : UserControl, BaseHeadImgItem
	{
		public delegate void DelItemClick(object sender, object object_0);
		public string strUserName;
		public bool bIsDelShown;
		public static HeadImgLoadService mHeadImgLoadService = new HeadImgLoadService(true);
		internal Button LayoutRoot;
		internal Image HeadImg;
		internal Image DelImg;
		private bool _contentLoaded;
		public event PostPhotoWithHeadImg.DelItemClick DelClick;
		public string UserName
		{
			get
			{
				return this.strUserName;
			}
			set
			{
			}
		}
		public PostPhotoWithHeadImg(string strName)
		{
			this.InitializeComponent();
			this.strUserName = strName;
			base.add_Loaded(new RoutedEventHandler(this.PostPhotoWithHeadImg_Loaded));
			base.add_Unloaded(new RoutedEventHandler(this.PostPhotoWithHeadImg_Unloaded));
		}
		private void PostPhotoWithHeadImg_Loaded(object sender, RoutedEventArgs e)
		{
			this.HeadImg.set_Source(HeadImgMgr.getHeadImage(this.UserName, true));
			this.DelImg.set_Source(new ImageSourceConverter().ConvertFromString("/Source/Plugin/Sns/Common/Resource/delete_icon.png") as ImageSource);
			this.DelImg.set_Visibility(1);
			PostPhotoWithHeadImg.mHeadImgLoadService.Add(this);
		}
		private void PostPhotoWithHeadImg_Unloaded(object sender, RoutedEventArgs e)
		{
			PostPhotoWithHeadImg.mHeadImgLoadService.Delete(this);
		}
		public void ResetState()
		{
			this.bIsDelShown = false;
			this.DelImg.set_Visibility(1);
		}
		private void RefreshHeadImg()
		{
			this.HeadImg.set_Source(HeadImgMgr.getHeadImage(this.UserName, true));
		}
		public void HeadImgLoaded()
		{
			this.RefreshHeadImg();
		}
		public void ScreenIn()
		{
		}
		public void ScreenOut()
		{
		}
		private void Button_Click(object sender, RoutedEventArgs e)
		{
			if (!this.bIsDelShown)
			{
				this.DelImg.set_Visibility(0);
				this.bIsDelShown = true;
			}
			else
			{
				this.bIsDelShown = false;
			}
			if (this.DelClick != null)
			{
				this.DelClick(this, this.strUserName);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/Sns/Common/UI/UploadAndPost/PostPhotoWithHeadImg.xaml", 2));
			this.LayoutRoot = (Button)base.FindName("LayoutRoot");
			this.HeadImg = (Image)base.FindName("HeadImg");
			this.DelImg = (Image)base.FindName("DelImg");
		}
	}
}
